From c3fd02a4509a1041e940a0dae57c9da791126d8d Mon Sep 17 00:00:00 2001 From: parkrrrr Date: Fri, 17 Sep 2004 20:14:06 +0000 Subject: [PATCH] Add ARGTYPE_HIDDEN flag and 'nowarn' flag for stack filter --- gpsbabel/defs.h | 1 + gpsbabel/filter_vecs.c | 3 ++- gpsbabel/stackfilter.c | 10 +++++++++- gpsbabel/testo | 7 ++----- gpsbabel/vecs.c | 7 ++++--- 5 files changed, 18 insertions(+), 10 deletions(-) diff --git a/gpsbabel/defs.h b/gpsbabel/defs.h index 807d3dc82..cf4ad1c36 100644 --- a/gpsbabel/defs.h +++ b/gpsbabel/defs.h @@ -325,6 +325,7 @@ void vmem_realloc(vmem_t*, size_t); #define ARGTYPE_FILE 0x00000005 #define ARGTYPE_OUTFILE 0x00000006 #define ARGTYPE_REQUIRED 0x40000000 +#define ARGTYPE_HIDDEN 0x20000000 #define ARGTYPE_TYPEMASK 0x00000fff #define ARGTYPE_FLAGMASK 0xfffff000 diff --git a/gpsbabel/filter_vecs.c b/gpsbabel/filter_vecs.c index aab1af133..f81c545b7 100644 --- a/gpsbabel/filter_vecs.c +++ b/gpsbabel/filter_vecs.c @@ -190,7 +190,8 @@ disp_filter_vecs(void) printf(" %-20.20s %-50.50s\n", vec->name, vec->desc); for (ap = vec->vec->args; ap && ap->argstring; ap++) { - printf(" %-18.18s %-.50s %s\n", + if ( !(ap->argtype & ARGTYPE_HIDDEN )) + printf(" %-18.18s %-.50s %s\n", ap->argstring, ap->helpstring, (ap->argtype&ARGTYPE_REQUIRED)?"(required)":""); } diff --git a/gpsbabel/stackfilter.c b/gpsbabel/stackfilter.c index d581bbb52..d9a82d98a 100644 --- a/gpsbabel/stackfilter.c +++ b/gpsbabel/stackfilter.c @@ -33,6 +33,8 @@ static char *opt_discard = NULL; static char *opt_replace = NULL; static char *opt_swap = NULL; static char *opt_depth = NULL; +static char *nowarn = NULL; +static int warnings_enabled = 1; static int swapdepth = 0; static @@ -52,6 +54,8 @@ arglist_t stackfilt_args[] = { {"swap", &opt_swap, "Swap waypoint list with item on stack", NULL, ARGTYPE_BOOL}, {"depth", &opt_depth, "Item to use when swapping", NULL, ARGTYPE_INT}, + {"nowarn", &nowarn, "Suppress cleanup warning", NULL, + ARGTYPE_INT | ARGTYPE_HIDDEN}, {0, 0, 0, 0, 0} }; @@ -121,6 +125,10 @@ stackfilt_init(const char *args) { int invalid = 0; + if ( nowarn ) { + warnings_enabled = 0; + } + if ( opt_depth ) { swapdepth = atoi( opt_depth ); } @@ -163,7 +171,7 @@ void stackfilt_exit( void ) { struct stack_elt *tmp_elt = NULL; - if ( stack ) { + if ( warnings_enabled && stack ) { warning( MYNAME " Warning: leftover stack entries; " "check command line for mistakes\n" ); } diff --git a/gpsbabel/testo b/gpsbabel/testo index 8fc52b5e2..fcd9d394a 100755 --- a/gpsbabel/testo +++ b/gpsbabel/testo @@ -590,12 +590,9 @@ compare ${TMPDIR}/Glad_5.exp reference # # stack filter tests # These don't actually test for proper behavior, for now, but they do -# exercise all of the currently-extant filter code except for the "clean -# up leftover stacks" code that would output a warning. Of course, that -# code is the most likely to generate memory leaks, so maybe we need a -# 'nowarn' option to the stack filter so we can test it... +# exercise all of the currently-extant filter code. # -${PNAME} -i geo -f geocaching.loc -x stack,push,copy -x stack,push,copy -x stack,push -x stack,pop,replace -x stack,pop,append -x stack,push,copy -x stack,pop,discard -x stack,swap,depth=1 -x stack,pop -o arc -F ${TMPDIR}/stackfilt.txt +${PNAME} -i geo -f geocaching.loc -x stack,push,copy,nowarn -x stack,push,copy -x stack,push -x stack,pop,replace -x stack,pop,append -x stack,push,copy -x stack,pop,discard -x stack,swap,depth=1 -o arc -F ${TMPDIR}/stackfilt.txt exit 0 diff --git a/gpsbabel/vecs.c b/gpsbabel/vecs.c index 3fab6bbee..3bfac7257 100644 --- a/gpsbabel/vecs.c +++ b/gpsbabel/vecs.c @@ -523,9 +523,10 @@ disp_vecs(void) for (i=0;iname, svp[i]->desc); for (ap = svp[i]->vec->args; ap && ap->argstring; ap++) { - printf(" %-18.18s %-.50s %s\n", - ap->argstring, ap->helpstring, - (ap->argtype & ARGTYPE_REQUIRED)?"(required)":""); + if ( !(ap->argtype & ARGTYPE_HIDDEN)) + printf(" %-18.18s %-.50s %s\n", + ap->argstring, ap->helpstring, + (ap->argtype & ARGTYPE_REQUIRED)?"(required)":""); } } -- 2.30.2